<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!--
Beyond Admin - Responsive Admin Dashboard Template build with Twitter Bootstrap 3
Version: 1.0.0
Purchase: http://wrapbootstrap.com
-->

<html xmlns="http://www.w3.org/1999/xhtml">
<!--Head-->
<head>
<%@ include file="/commonadmin/include/admin_include.jsp" %>

<meta name="description" content="register page" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon"
	href="<%=request.getContextPath()%>/commonadmin/assets/img/favicon.png"
	type="image/x-icon">

<!--Basic Styles-->
<link
	href="<%=request.getContextPath()%>/commonadmin/assets/css/bootstrap.min.css"
	rel="stylesheet" />
<link id="bootstrap-rtl-link" href="" rel="stylesheet" />
<link
	href="<%=request.getContextPath()%>/commonadmin/assets/css/font-awesome.min.css"
	rel="stylesheet" />

<!--Fonts-->
<link
	href="<%=request.getContextPath()%>/commonadmin/js/font-useso.js"
	rel="stylesheet" type="text/css">

<!--Beyond styles-->
<link
	href="<%=request.getContextPath()%>/commonadmin/assets/css/beyond.min.css"
	rel="stylesheet" />
<link
	href="<%=request.getContextPath()%>/commonadmin/assets/css/demo.min.css"
	rel="stylesheet" />
<link
	href="<%=request.getContextPath()%>/commonadmin/assets/css/animate.min.css"
	rel="stylesheet" />
<link id="skin-link" href="" rel="stylesheet" type="text/css" />

<!--Skin Script: Place this script in head to load scripts for skins and rtl support-->
<script
	src="<%=request.getContextPath()%>/commonadmin/assets/js/skins.min.js"></script>
</head>

<!--Head Ends-->
<!--Body-->
<body>
	<form id="" method="post" enctype="multipart/form-data" action="<%=request.getContextPath()%>/admin/interest/editInterest.htm"  data-ajax="false">	
		<div class="register-container animated fadeInDown">
			<div class="registerbox bg-white">
				<div class="registerbox-caption "></div>
				<div class="registerbox-caption "></div>
				<div class="registerbox-caption "></div>
				<div class="registerbox-title" style="text-align: center;">修改兴趣</div>

				<div class="registerbox-caption "></div>
				<div class="registerbox-caption "></div>
				<div class="registerbox-textbox">
					<input type="text" class="form-control" placeholder="兴趣名称:"
						name="interest_name" id="interest_name" required accunt/>
				</div>
				<div class="registerbox-caption "></div>
				<div class="registerbox-textbox">
					<input type="password" class="form-control" placeholder="兴趣图片:"
						id="password" name="password" required/>
				</div>
				
				<div id="label_1" style="padding-left:0%;width: 100%">
						    <input type="hidden" name="resource_id" value="${resourceList.resourceId }" />
							<img class="default" src="http://www.yihaoxue.net/common/img/default.png" id="idCardFrontImg" width="100%" />
								<div class="fileUpload_div">
									<input type="file" class="fileUpload_class" id="picture" name="uploadImg" data-role="none" class="input" required onchange="javascript:setImagePreview(this.id,'idCardFrontImg');"/>
								</div>
							<p style="padding:2% 0;color:#a9a9a9">兴趣图片：上传照片(照片请小于1M)</p>
						</div>
				</div>
				<div class="registerbox-submit">
					<input type="submit" class="btn btn-primary pull-left" value="添加">
				</div>
				<div class="registerbox-submit">
					<input type="button" class="btn btn-primary pull-right" value="关闭"
						onclick="window.close()">
				</div>
			</div>
		</div>
	</form>
	
	<!--Basic Scripts-->
	<%-- <script src="<%=request.getContextPath()%>/commonadmin/assets/js/jquery-2.0.3.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/commonadmin/component/jquery/jquery.validate.js"></script> --%>
	<script
		src="<%=request.getContextPath()%>/commonadmin/assets/js/bootstrap.min.js"></script>

	<!--Beyond Scripts-->
	<script
		src="<%=request.getContextPath()%>/commonadmin/assets/js/beyond.min.js"></script>
	<script type="text/javascript">
$(function (){
	var imagePath =$("#imagePath").val();
	if(imagePath.trim() !=""){
		$("#idCardFrontImg").attr("src","<%=request.getContextPath()%>/"+imagePath );
	}
})
function setImagePreview(fileId, showImagesId) {  
		//toShowLoading();
		var preview, img_txt, localImag, file_head = document.getElementById(fileId),  
		picture = file_head.value;
		if(picture == ''){
			preview = document.getElementById(showImagesId);
			preview.src = "<%=basePath %>common/img/default.png";
		}
		if (!picture.match(/.jpg|.png|.bmp/i) && picture != '') return alert("您上传的图片格式不正确，请重新选择！"),  
		!1;  
		 
		if (preview = document.getElementById(showImagesId), file_head.files && file_head.files[0]){
				preview.style.display = "block",
	            preview.style.height = $("#" + showImagesId).height() + "px",  
				preview.src = window.navigator.userAgent.indexOf("Chrome") >= 1 || window.navigator.userAgent.indexOf("Safari") >= 1 ?  window.webkitURL.createObjectURL(file_head.files[0]) : window.URL.createObjectURL(file_head.files[0]); 
				var tmpCanvas = document.getElementById("canvas_tmp");
				var tmpContext = tmpCanvas.getContext("2d");
				var image = document.getElementById("idCardFrontImg");
				var reader = new FileReader();
	

				reader.onload = function(evt) {
					image.src = evt.target.result;
					var hideImg = document.getElementById("hideImg");
					hideImg.src = evt.target.result;				
					hideImg.onload = function(){
				        // canvas清屏  
				        tmpContext.clearRect(0, 0, tmpCanvas.width, tmpCanvas.height);  
				      
					    // 重置canvas宽高  	
				        tmpCanvas.width = hideImg.width;  
				        tmpCanvas.height = hideImg.height;
				        // 将图像绘制到canvas上  
				        tmpContext.drawImage(hideImg, 0, 0, hideImg.width, hideImg.height);
					    var Pic = document.getElementById("canvas_tmp").toDataURL("image/png");
						Pic = Pic.replace(/^data:image\/(png|jpg);base64,/, "");
					    
				    if(Pic!=undefined){
						$("#fixedAvatar").val(Pic);
							toHideLoading();
						}
					}
				}
				reader.readAsDataURL(file_head.files[0]);
				
		}
	}
	</script>
</body>
<!--Body Ends-->
</html>
